﻿#include "chinese.h"
#pragma once

#include <QObject>
#include <QProcess>
#include <QRegularExpression>
#include <QString>
#include <QStringList>

#include "appcommon.h"

class ServiceUtils {
public:
    struct ServiceInfo {
        QString serviceName;  ///< 服务名称
        QString serviceState; ///< 安装状态
        QString load;         ///< 加载状态
        QString active;       ///< active
        QString sub;          ///< 详细运行状态
        QString description;  ///< 描述
    };

    static QList<ServiceInfo> getInstalledServiceList(bool ascending, const QString &grepPattern,
                                                      const QString &state);

    static QPair<int, QList<ServiceUtils::ServiceInfo>>
    getInstalledServiceList(bool ascending, const QString &grepPattern, int pageNum, int pageSize,
                            const QString &state);

    static ShellUtils::ShellResult status(const QString &serviceName);

    static ShellUtils::ShellResult operate(const QString &serviceName, const QString &operateType);

    static ShellUtils::ShellResult reload();

    /// 是否开机自启
    static bool isEnabled(const QString &serviceName);
};
